package com.juku2024.juku.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.model.CommonModel
import com.juku2024.juku.tools.AppUtils
import com.juku2024.juku.tools.ImageUtils
import java.util.*

class WatchListAdapter(data: ArrayList<CommonModel>) :
    BaseQuickAdapter<CommonModel, BaseViewHolder>(R.layout.item_watching, data), LoadMoreModule {

    var isMovie = false

    override fun convert(holder: BaseViewHolder, item: CommonModel) {
        val iv = holder.getView<ImageView>(R.id.iv_home)
        ImageUtils.loadImage(iv, item.pic)
        val colorId = if (isMovie)
            R.color.cFF6D2F
        else
            R.color.cFFFFFF
        val tag = if (isMovie) {
            item.score
        } else {
            item.update_progress
        }
        holder.setText(R.id.tv_update, tag)
            .setText(R.id.tv_title, item.name)
            .setTextColor(R.id.tv_update, AppUtils.getColor(colorId))

        // 更新
        holder.setGone(R.id.layoutUpdate, item.isVideoUpdate != true)
    }

}